export function useWithdrawalCache() {
  const { userInfo } = storeToRefs(useUserStore());

  function getCacheKey(chain: string, currency: string) {
    if (!userInfo.value?.uid || !chain || !currency)
      return void 0;
    return `WITHDRAWAL_M_${chain}_${currency}_${userInfo.value?.uid}`;
  }

  function getCache(chain: string, currency: string) {
    const key = getCacheKey(chain, currency);
    return key ? (localStorage.getItem(key) as string) : null;
  }

  function setCache(address: string, chain: string, currency: string) {
    const key = getCacheKey(chain, currency);
    key && address && localStorage.setItem(key, address);
  }

  function removeCache(chain: string, currency: string) {
    const key = getCacheKey(chain, currency);
    key && localStorage.removeItem(key);
  }

  return { getCache, setCache, removeCache };
}

window.localStorage;
